{extend name="layout"}

{block name="content"}
    <!-- wrapper-content -->
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-lg-12">

				<div class="ibox-content m-b-sm border-bottom">
					<div class="p-xs">
						<div class="float-left m-r-md">
							<i class="fa fa-key text-navy mid-icon"></i>
						</div>
						<h2>系统用户管理</h2>
						<span>一个管理员可以有多个角色组的管理权,左侧的菜单根据管理员所拥有的权限进行生成。</span>
					</div>
				</div>

				<div class="ibox ">
					<div class="ibox-title">
						<h5>系统用户管理 </h5>
					</div>
					<div class="ibox-content">
						<div class="row m-b">
							<div class="col-sm-12">
								<form method="get" action="" id="form">
									<div class="search-bar row">

										<div class="input-group col-sm-5">
											<div class="input-group-prepend">
												<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button" aria-expanded="false">
												{switch :input('get.status')}
													{case 1}使用中{/case}
													{case 2}已禁用{/case}
													{default}全部状态
												{/switch}
												</button>
												<input type="hidden" name="status" value="{:input('get.status')}" />
												<ul class="dropdown-menu" x-placement="bottom-start"
													style="position: absolute; top: 35px; left: 0px; will-change: top, left;">
													<li>
														<a class="search-dropdown" data-value="0"
															href="javascript:void(0)" data-name="status">全部状态</a>
													</li>
													<li>
														<a class="search-dropdown" data-value="1"
															href="javascript:void(0)" data-name="status">使用中</a>
													</li>
													<li>
														<a class="search-dropdown" data-value="2"
															href="javascript:void(0)" data-name="status">已禁用</a>
													</li>
												</ul>
											</div>
											<div class="input-group-prepend">
												<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button" aria-expanded="false">
													{volist name="role_list" id="vo" key="k"}
														{if input('get.group_id')==$key}{$vo}{/if}
													{/volist}
													{if !input('get.group_id') }全部组员{/if}
												</button>
												<input type="hidden" name="group_id" value="{:input('get.group_id')}" />
												<ul class="dropdown-menu" x-placement="bottom-start" style="position: absolute; top: 35px; left: 0px; will-change: top, left;">
													<li>
														<a class="search-dropdown" data-value="" href="javascript:void(0)" data-name="group_id">全部组员</a>
													</li>
													{volist name="role_list" id="vo" key="k"}
													<li>
														<a class="search-dropdown" data-value="{$key}" href="javascript:void(0)" data-name="group_id">{$vo}</a>
													</li>
													{/volist}
												</ul>
											</div>

											<div class="input-group-prepend">
												<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button" aria-expanded="false">
													{switch :input('get.type')}
													{case 1}ID{/case}
													{case 2}用户名{/case}
													{case 3}昵称{/case}
													{case 4}邮箱{/case}
													{default}不限
													{/switch}
												</button>
												<input type="hidden" name="type" value="{:input('get.type')}" />
												<ul class="dropdown-menu" x-placement="bottom-start"
													style="position: absolute; top: 35px; left: 0px; will-change: top, left;">
													<li>
														<a class="search-dropdown" data-name="type" data-value="0"
															href="javascript:void(0)">不限</a>
													</li>
													<li>
														<a class="search-dropdown" data-name="type" data-value="1"
															href="javascript:void(0)">ID</a>
													</li>
													<li>
														<a class="search-dropdown" data-name="type" data-value="2"
															href="javascript:void(0)">用户名</a>
													</li>
													<li>
														<a class="search-dropdown" data-name="type" data-value="3"
															href="javascript:void(0)">昵称</a>
													</li>
													<li>
														<a class="search-dropdown" data-name="type" data-value="4"
															href="javascript:void(0)">邮箱</a>
													</li>
												</ul>
											</div>
											<input type="text" name="keyword" class="form-control" value="{:input('get.keyword')}">
										</div>

										<div class="input-group input-daterange col-sm-5">
											<input id="data_start" name="data_start" type="text" placeholder="创建日期(起)" data-date-format="yyyy-mm-dd"
												class="form-control" value="{:input('get.data_start')}" />
											<div class="input-group-addon"> ~ </div>
											<input id="data_end" name="data_end" type="text" placeholder="创建日期(止)" data-date-format="yyyy-mm-dd"
												class="form-control" value="{:input('get.data_end')}" />
										</div>

										<button class="btn btn-primary ml-3" type="submit"><i class="fa fa-search"></i>
											搜索</button>

									</div>
								</form>

							</div>
						</div>

						<div class="row m-b">
							<div class="col-sm-12">
								<div class="toolbar-btn-action">
									<a href="javascript:;" class="btn btn-primary btn-refresh page-reload" title="刷新"><i
											class="fa fa-refresh"></i> </a>
									<a title="添加" class="btn btn-success" href="{:url('admin/user/add')}"><i
											class="fa fa-plus-circle"></i> 添加</a>
									<a title="启用" class="btn btn-success ajax-post confirm" target-form="ids"
										href="{:url('admin/user/editStatus?type=1')}"><i
											class="fa fa-check-circle-o"></i> 启用</a>
									<a title="禁用" class="btn btn-warning ajax-post confirm" target-form="ids"
										href="{:url('admin/user/editStatus?type=2')}"><i
											class="fa fa-ban"></i> 禁用</a>
									<a title="删除" class="btn btn-danger ajax-post confirm" target-form="ids"
										href="{:url('admin/user/delete')}"><i
											class="fa fa-times-circle-o"></i> 删除</a>
								</div>
							</div>
						</div>

						<div class="table-responsive">
							<table class="table table-bordered table-hover">
								<thead>
									<tr>
										<th><input type="checkbox" class="i-checks checkbox-master"> </th>
										<th>ID </th>
										<th>头像 </th>
										<th>用户名 </th>
										<th>昵称</th>
										<th>角色</th>
										<th>邮箱</th>
										<th>状态</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									{volist name="list" id="data"}
									<tr>
										<td class="align-middle">{if $data.uid!=1}<input type="checkbox" class="i-checks ids" name="ids[]" value="{$data.uid}">{/if}</td>
										<td class="align-middle">{$data.uid}</td>
										<td class="align-middle">
											<a href="{$data.avatar|default='__ADMIN_IMG__/avatar.png'}" title="{$data.nickname}" data-gallery=""><img
													src="{$data.avatar|default='__ADMIN_IMG__/avatar.png'}" alt="{$data.nickname}"
													style="max-height:40px;max-width:40px"></a>
										</td>
										<td class="align-middle">{$data.username}</td>
										<td class="align-middle">{$data.nickname}</td>
										<td class="align-middle">{$role_list[$data.group_id]}</td>
										<td class="align-middle">{$data.email}</td>
										<td class="align-middle">
											账号创建于 <span class="text-info">{$data.create_time|date='Y年m月d日 H:i:s'}</span>，共登录了 <span
												class="text-info">{$data.login_num}</span> 次<br>
											{if $data.login_num>0}
											最近于 <span class="text-info">{$data.last_login_time|date='Y年m月d日 H:i:s'}</span> 通过 <span
												class="text-info">{$data.last_login_ip}</span> 登录，
												{if $data.status==1}
													<b class="text-success">使用中</b>
												{else}
													<b class="text-warning">禁用中</b>
												{/if}
											{else /}
											<span class="text-muted">该账号还没有登录过哦，登录之后才会有记录！</span>
												{if $data.status==1}
													<b class="text-success">使用中</b>
												{else}
													<b class="text-warning">禁用中</b>
												{/if}
											{/if}
										</td>
										<td class="align-middle tooltip-demo">
											{if $data.uid!=1}
											<a href="{:url('admin/user/edit?id='.$data.uid)}" class="btn btn-primary btn-xs"
												_tag="edit" data-toggle="tooltip" data-placement="top" title="修改"><i
													class="fa fa-pencil"></i></a>
												{if $data.status==1}
												<a href="{:url('admin/user/editStatus?id='.$data.uid.'&type=2')}"
													class="btn btn-warning btn-xs ajax-get confirm" _tag="disable"
													data-toggle="tooltip" data-placement="top" title="禁用"><i class="fa fa-close"></i></a>
												{else /}
												<a href="{:url('admin/user/editStatus?id='.$data.uid.'&type=1')}" class="btn btn-success btn-xs ajax-get confirm"
													_tag="enable" data-toggle="tooltip" data-placement="top" title="启用"><i class="fa fa-check"></i></a>
												{/if}
											<a href="{:url('admin/user/delete?id='.$data.uid)}"
												class="btn btn-danger btn-xs ajax-get confirm" _tag="delete"
												data-toggle="tooltip" data-placement="top" title="删除"><i
													class="fa fa-trash"></i></a>
											{/if}
										</td>
									</tr>
									{/volist}
									
								</tbody>
							</table>

							<!-- The Gallery as lightbox dialog, should be a child element of the document body -->
							<div id="blueimp-gallery" class="blueimp-gallery">
								<div class="slides"></div>
								<h3 class="title"></h3>
								<a class="prev">‹</a>
								<a class="next">›</a>
								<a class="close">×</a>
								<a class="play-pause"></a>
								<ol class="indicator"></ol>
							</div>

							{$page|raw}

						</div>

					</div>
				</div>

			</div>
		</div>

	</div>

{/block}
